package com.desaysv.hicar;

import android.content.Context;
import android.location.Location;
import android.os.Build;
import android.os.Message;
import android.util.Log;

import androidx.annotation.RequiresApi;

import com.desaysv.svhttp.utils.SVUtils;

import java.io.IOException;
import java.io.InputStream;

import javax.security.cert.CertificateException;
import javax.security.cert.X509Certificate;

public class LocationUtils {
    private Context mContext;
    private LocationManager mLocationManager;

    public interface LocationCallBack{
        void callBack(Location location);
        void numCall(int nums);
    }

    public void init(Context context,int type, LocationCallBack call){
        this.mContext=context;
//        mLocationManager= (LocationManager)mContext.getSystemService(Context.LOCATION_SERVICE);

    }

    @RequiresApi(api = Build.VERSION_CODES.N)
    private void del(long[]data){
        StringBuilder params=new StringBuilder();
        for (int i = 0; i < data.length; i++) {
            params.append(data[i]);
            if(i!=data.length-1){
                params.append(",");
            }
        }


        StringBuilder builder=new StringBuilder();
        builder.append("DELETE FROM CallRecord WHERE ");
        builder.append("( ");
        builder.append("CallRecord.contactId IS NOT NULL AND CallRecord.contactId IN ");
        builder.append("( ");
        builder.append(params.toString());
        builder.append(") ");
        builder.append(") ");

        builder.append(" OR ");

        builder.append("( ");
        builder.append("CallRecord.groupId IS NOT NULL AND CallRecord.groupId IN ");
        builder.append("( ");
        builder.append(params.toString());
        builder.append(") ");
        builder.append(") ");

        builder.append(" OR ");

        builder.append("( ");
        builder.append("CallRecord.groupId IS NOT NULL AND CallRecord.groupId IN ");
        builder.append("( ");
        builder.append(params.toString());
        builder.append(") ");
        builder.append(") ");

    }
    private static final int SEND_TYPE_SINGLIN=0;
    private static final int SEND_TYPE_MSRP=1;
    public void sendMessage(int type, Message message){
        //把这个type暴露给前端，让前端进行抉择,但是这个值你要定好约束
        switch (type){
            case SEND_TYPE_MSRP:
                //媒体层消息
                break;
            case SEND_TYPE_SINGLIN:
                //信令层消息
                break;
            default:
                Log.e("","请传入正确的类型");
        }
    }


    public static void getSign(Context context) throws IOException, CertificateException {
        InputStream in=context.getAssets().open("csr.pem");
        InputStream pk=context.getAssets().open("private.key");
        X509Certificate cert=X509Certificate.getInstance(in);
        byte[]pkByte=SVUtils.streamTobyte(pk);

    }
}
